package com.sgmw.sales.tool.kong.sign.request.body;

import java.util.LinkedHashMap;
import java.util.Map.Entry;

public class RequestBodyForm implements RequestBody {
	private LinkedHashMap<String, String> params;

	@Override
	public String getContent() {
		int i = 0;
		StringBuilder sb = new StringBuilder();
		if (params != null) {
			for (Entry<String, String> entry : params.entrySet()) {
				if (i == 0) {
					sb.append(entry.getKey()).append("=").append(entry.getValue());
				} else {
					sb.append("&").append(entry.getKey()).append("=").append(entry.getValue());
				}
				i++;
			}
		}

		return sb.toString();
	}

	public RequestBodyForm(LinkedHashMap<String, String> params) {
		this.params = params;
	}
}
